//
//  HPlikeHeadView.swift
//  GZWeibo007
//
//  Created by  何平 on 15/12/24.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

class HPlikeHeadView: UIView {
    
   
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
        
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        //backgroundColor = UIColor.grayColor()
        // 准备UI
        preapreUI()
       backgroundColor = UIColor(white: 0.98, alpha: 1)
    }
    
     private func preapreUI(){
        //--1:转发
        addSubview(forwardButton)
        //--2:评论
        addSubview(commentButton)
        //--3:点赞
        addSubview(likeButton)
        
        forwardButton.translatesAutoresizingMaskIntoConstraints=false
        commentButton.translatesAutoresizingMaskIntoConstraints=false
        likeButton.translatesAutoresizingMaskIntoConstraints=false
        
        //--转发按扭垂直中心约束
        addConstraint(NSLayoutConstraint(item: forwardButton, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0))
        //--转发按扭左边约束
        addConstraint(NSLayoutConstraint(item: forwardButton, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Left, multiplier: 1, constant: 8))
        //--转发按扭宽度约束
        addConstraint(NSLayoutConstraint(item: forwardButton, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 50))
        //--转发按扭高度约束
        addConstraint(NSLayoutConstraint(item: forwardButton, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.Height, multiplier: 1, constant: 40))
        
        //--评论按扭垂直中心约束
        addConstraint(NSLayoutConstraint(item: commentButton, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0))
        //--评论按扭左边约束
        addConstraint(NSLayoutConstraint(item: commentButton, attribute: NSLayoutAttribute.Left, relatedBy: NSLayoutRelation.Equal, toItem: forwardButton, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: 20))
        //--评论按扭宽度约束
        addConstraint(NSLayoutConstraint(item: commentButton, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 50))
        //--评论按扭高度约束
        addConstraint(NSLayoutConstraint(item: commentButton, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.Height, multiplier: 1, constant: 40))
        
        //--点赞按扭垂直中心约束
        addConstraint(NSLayoutConstraint(item: likeButton, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.CenterY, multiplier: 1, constant: 0))
        //--点赞按扭右边约束
        addConstraint(NSLayoutConstraint(item: likeButton, attribute: NSLayoutAttribute.Right, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.Right, multiplier: 1, constant: -8))
        //--点赞按扭宽度约束
        addConstraint(NSLayoutConstraint(item: likeButton, attribute: NSLayoutAttribute.Width, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.NotAnAttribute, multiplier: 1, constant: 50))
        //--点赞按扭高度约束
        addConstraint(NSLayoutConstraint(item: likeButton, attribute: NSLayoutAttribute.Height, relatedBy: NSLayoutRelation.Equal, toItem: nil, attribute: NSLayoutAttribute.Height, multiplier: 1, constant: 40))

    }
    
    // MARK: - 点赞头部view懒加载
    //--1:转发
    private lazy var forwardButton:UIButton = {
        let forwardButton = UIButton();
        forwardButton.setTitle("转发", forState: UIControlState.Normal)
        forwardButton.setTitleColor(UIColor.grayColor(), forState: UIControlState.Normal)
        forwardButton.setTitleColor(UIColor.blackColor(), forState: UIControlState.Highlighted)
        return forwardButton
    }()
    
    //--2:评论
    private lazy var commentButton:UIButton = {
        let commentButton = UIButton();
        commentButton.setTitle("评论", forState: UIControlState.Normal)
        commentButton.setTitleColor(UIColor.grayColor(), forState: UIControlState.Normal)
        commentButton.setTitleColor(UIColor.blackColor(), forState: UIControlState.Highlighted)
        return commentButton
    }()
    
    //--3:点赞
    private lazy var likeButton:UIButton = {
        let likeButton = UIButton();
        likeButton.setTitle("赞", forState: UIControlState.Normal)
        likeButton.setTitleColor(UIColor.grayColor(), forState: UIControlState.Normal)
        likeButton.setTitleColor(UIColor.blackColor(), forState: UIControlState.Highlighted)
        return likeButton
    }()
}


